
using Microsoft.EntityFrameworkCore;
using WebAuth.Models;
using DbContext = Microsoft.EntityFrameworkCore.DbContext;

namespace WebAuth.DAO
{
    public class UapDbContext : DbContext
    {
        public DbSet<User> Users { get; set; }
        public DbSet<Department> Departments { get; set; }
        public DbSet<Role> Roles { get; set; }
        public DbSet<AuthBinder> AuthBinders { get; set; }
        public DbSet<AuthGroup> AuthGroups { get; set; }
        public DbSet<AuthItem> AuthItems { get; set; }

        

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            // optionsBuilder.UseSqlServer(ConfigurationManager.ConnectionStrings["MsSqlConnection"].ConnectionString);
            string conStr;
            conStr =
                "server=localhost;port=3306;database=UAP;user=root;password=123456;Charset=utf8;SslMode=None";
            optionsBuilder.UseMySql(conStr);
            /*
            switch (type.ToUpper())
            {
                case "MYSQL":
                    conStr =
                        "server=localhost;port=3306;database=UAP;user=root;password=123456;Charset=utf8;SslMode=None";
                    optionsBuilder.UseMySql(conStr);
                    break;
                default:
                    conStr =
                        "server=localhost;port=3306;database=UAP;user=root;password=123456;Charset=utf8;SslMode=None";
                    optionsBuilder.UseSqlServer(conStr);
                    break;
            }
            */

            // "Server=.;Database=(local);uid=sa;pwd=1983032483hyk!;DataBase=UAP;Trusted_Connection=True;ConnectRetryCount=0";
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            // modelBuilder.HasDefaultSchema("UAP");
        }
    }
}